Repository navigation
perf(security): reject obfuscated scans with no targeted gap - #2
Closed
rufushsu9987 wants to merge 1147 commits into
Closed
rufushsu9987 wants to merge 1147 commits into
rufushsu9987 wants to merge 1147 commits into
Conversation
… semantics Address the fourth review round. - A forwarded **kwargs (a function's own ** parameter passed on) binds only into the callee's own ** parameter: one slot per callee, and it never fills named, keyword-only or receiver parameters. This removes the per-name expansion (up to 85 targets per **k) and the false positives from one tainted keyword reaching every forwarded one. - A source call's value is what it reads, not its arguments, so json.load(open(os.getenv(...))) is TT4 again, as on main. - Sinks cite variables main's flows taint (phase A) before parameters only the new flows bind, so same-rule messages keep main's wording. - A class-body read of a name the class binds reads a view fed by the module and class keys; the class attribute keeps only the class's own value. Any class-body binding (annotated assignment, import, def) shadows a base's value; an annotation alone binds nothing. - An immediately called lambda in a default yields its body's value. - C3 merges every base and caps only the result. - Deadline checks per argument and keyword in bind_arguments and every 1,024 flows of one key in drain. - CHANGELOG: exact fingerprints are version-bound; list every message change category and raised rule. Tests pin each case, add non-root nested-default and many-base scaling shapes, the forwarded-kwargs cost, the slot-cap boundary for *rest, the multi-base ancestor cap, C3 local precedence, and non-constructor self()/cls() calls. Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bring in the main merges the update-branch workflow added to the PR branch (NVIDIA#791, NVIDIA#792) while the fixes were in progress. Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the conflict in static_patterns_tool_misuse.py: keep this branch's _is_assigned_value next to main's new _bounded_context and _raw_classification_bounds helpers, and use main's line_number() in the TM3 loop after the assigned-umask skip. Signed-off-by: Ilai Goldschmidt <117302862+ilaigold@users.noreply.github.com>
Signed-off-by: Mohit Gupta <mohgupta@nvidia.com>
…-paths fix(report): preserve archive member provenance in JSON
class D(Base, Mixin) with Base(Root) must resolve Root.handle before Mixin.handle, as CPython's MRO does. Add that shape and a twin whose Root.handle is harmless to the C3 test. Merging the bases list first, or merging the bases in reverse, now fails the test. Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Flag a base64, base32, xxd or openssl decoder whose output is piped to a shell or a stdin-reading interpreter, passed to eval, sh -c or python -c, or fed to a shell or source through process substitution or a here-string. These rules run on every file type, so SKILL.md and hook configs are covered. Decode literal base64, base32 or hex payloads given to these decoders and re-apply SC2, as the XOR helper does. Variables, files and downloads stay opaque. Signed-off-by: Raj Zalavadia <rzalavad@redhat.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
) * fix(batch): preserve malformed response failures in compatibility mode Signed-off-by: yashrajbasav <yashrajbasav@nvidia.com> * fix(batch): preserve analyzer deadlines through compatibility initialization Signed-off-by: yashrajbasav <yashrajbasav@nvidia.com> * fix(meta): reject invalid stringified response fields Signed-off-by: yashrajbasav <yashrajbasav@nvidia.com> * test(meta): import result schema for validation regressions Signed-off-by: yashrajbasav <yashrajbasav@nvidia.com> * test(meta): enable parametrized invalid response coverage Signed-off-by: yashrajbasav <yashrajbasav@nvidia.com> * Update meta response validation expectations Signed-off-by: yashrajbasav <yashrajbasav@nvidia.com> * Format malformed response regressions Signed-off-by: yashrajbasav <yashrajbasav@nvidia.com> * fix: preserve valid compat verdicts and guard timeout forwarding Signed-off-by: yashrajbasav <yashrajbasav@nvidia.com> * fix: respect shorter compatibility request deadlines Signed-off-by: yashrajbasav <yashrajbasav@nvidia.com> * fix: bound pooled request waiting and retries by one deadline Signed-off-by: yashrajbasav <yashrajbasav@nvidia.com> * style: format compatibility regression checks Signed-off-by: yashrajbasav <yashrajbasav@nvidia.com> --------- Signed-off-by: yashrajbasav <yashrajbasav@nvidia.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Conflict came from main's TM3 umask fix (94547bd/3eb3cd93, PR NVIDIA#783), which added the _is_assigned_value skip to the TM3 match loop that this branch instruments with runtime_check(). Kept both: runtime_check() runs first, then main's assigned-umask skip. Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since NVIDIA#828, the shipped-bytecode walk counts only its own CPU time against the 5-second budget, and the workflow wall-clock deadline bounds elapsed time. Word the resource-bounds row the same way as the YARA rule-load row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
…failures fix: report incomplete batch gap-fill analysis
…ope-analysis fix(analyzer): reuse tool-misuse context indexes and honor deadlines
…ut-race fix: prevent report output symlink races
docs(bounds): describe the SC8 budget as active processing time
…boundaries Keep main's module-level _BIDI_CONTROL_PATTERN block (NVIDIA#473) next to the P2 identifier-boundary constants; the P2_PATTERNS list merges without the bidi entry. Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Two review blockers on NVIDIA#452: - `<!-->` and `<!--->` are abrupt empty comments; the HTML tokenizer closes them immediately. A P2 match no longer starts there, so the visible text after them is not reported as hidden up to a later `-->`. - `<!-- PLEASEIGNOREPREVIOUSINSTRUCTIONS -->` has no separator or case transition, so identifier boundaries dropped a hidden instruction that main flags. `ignore`, `instruction(s)` and `transmit` rarely occur inside ordinary words, so they match as substrings again. `system`, `POST`, `GET` and `send` keep identifier boundaries, which is what keeps SYSTEMATIC, POSTGRES, GETTING and target from matching. Direct and graph-level regressions cover both forms, including a real hidden comment after an abrupt empty comment. Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
…ent-boundaries Fix P2 HTML comment boundary matching
…istry-option-validation Reject unsupported skill options in registry mode
…-hardware-reset-state fix(mp3): recognize descriptive hardware reset states
…nment-final-state fix(tm1): use the final repeated assignment target
…ursive-shipped-baseline fix(cli): reject shipped baselines in recursive multi-skill scans
…ursive-risk-recommendation fix(report): align recursive risk recommendations
The Unicode security view spent most of its time in per-character Python loops inside the obfuscated-instruction automaton, even on prose that cannot contain a targeted vocabulary gap. Fold ASCII skeletons through a 128-entry table, cache non-ASCII skeletons by character, and skip the automaton when a linear projection cannot spell a gapped vocabulary word. Detection is unchanged: the reject is a superset of texts the exact automaton can accept, and a miss still runs that automaton. Runtime checks stay bounded on the reject path. Signed-off-by: HSU Yu Chen <rufushsu9987@users.noreply.github.com> Co-authored-by: Rufus Hsu <rufushsu9987@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes NVIDIA#866.
The Unicode security view was spending almost all of its time in per-character Python loops inside the obfuscated-instruction automaton (
_fold_security_character,_security_skeleton_piece,_has_security_word_character_before), including on ordinary prose that cannot contain a targeted vocabulary gap. This skips that automaton when a linear projection shows no such gap, and keeps the exact scan for everything else.This does not overlap with NVIDIA#583. That change seeks token gaps, narrows the confusable class, and caches normalized views. It does not change
_obfuscated_instruction_matches. No other open PR references NVIDIA#866.What changed
lru_cache(8192)), not per document.ignore previous instructionsare not candidates.finditerinstead of a freshre.searchat every idle cursor. Each consumption, including the final miss, still checks the runtime once. A reject checks once up front, once per 4096 characters, and once after the scan, so a long plain input stays cancellable.security_reconstruction.pyare unchanged. On accented input,security_text_viewsis still dominated by the letter-spacing walk when a runtime check is installed.Benchmark
uv run python tests/benchmarks/bench_unicode_security_view.pyon a 431,000-character paragraph (the input size from NVIDIA#866). Best of 5, Linux, Python 3.12. The "exact automaton" column is the previous scanner.security_text_views+ runtime, ASCIIsecurity_text_views+ runtime, accentedAn obfuscated tail does not take the reject, so that pair stays on the exact automaton. The issue's ~20 KB/s figure is whole-program time across many windows; this table is one 431 KB pass.
Test plan
uv run pytest -q(non-integration, non-provider): 14,779 passed, 20 skipped, 250 deselected, 4 xfailed.ruff check,ruff format --check, andmypyonsrc/skillspector/artifacts.pyand the new tests.AI assistance: Cursor Grok 4.7 assisted with investigation, implementation, regression tests, and review.